package ch.sfug.anim.tween.property {
	import flash.display.DisplayObject;
	
	import ch.sfug.anim.tween.CompositeTween;		

	/**
	 * @author loop
	 */
	public class Fader extends CompositeTween {

		public function Fader( t:DisplayObject = null, d:uint = 1000 ) {
			tween = new PropertyTween(t, d);
		}

		
		/**
		 * fades an object to a new alpha value.
		 */
		public function fadeTo( a:Number, ease:Function = null ):void {
			PropertyTween( tween ).tween({ alpha: { to:a, easing:ease } });
		}

		
		/**
		 * fades an object from an alpha value to a new alpha value.
		 */
		public function fadeFromTo( afrom:Number, ato:Number, ease:Function = null ):void {
			PropertyTween( tween ).tween({ alpha: { from:afrom, to:ato, easing:ease } });
		}

		
		/**
		 * sets the target the fade
		 */
		public function set target( d:DisplayObject ):void {
			tween.target = d;
		}

		
		/**
		 * returns the display object that fades
		 */
		public function get target(  ):DisplayObject {
			return DisplayObject(tween.target);
		}

		/**
		 * sets the duration of the mover
		 */
		public function set duration( n:Number ):void {
			tween.duration = n;
		}
		
		/**
		 * returns the duration of the mover
		 */
		public function get duration( ):Number {
			return tween.duration;
		}
		
		/**
		 * applies a alpha value
		 */
		public function apply( a:Number ):void {
			PropertyTween( tween ).apply({ alpha:a });
		}
	}
}
